<template>
  <z-modal
    :width="800"
    v-bind="modalOption"
    :okText="false"
    @ok="handleOk"
    @cancel="handleCancel"
  >
    <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="disableSubmit">
      <a-form-model slot="detail" layout="horizontal" labelAlign="right" ref="ruleForm" :label-col="labelCol" :wrapper-col="wrapperCol" :model="form" :rules="validatorRules">
        <a-form-model-item label="规格名称" prop="specName">
          <a-input placeholder="请输入规格名称" v-model.trim="form.specName" />
        </a-form-model-item>
        <a-form-model-item label="项目" prop="productName">
          <a-input-search v-model="form.productName" readOnly @search="onSearchProduct" placeholder="" >
          	<a-button slot="enterButton" >选择项目</a-button>
          </a-input-search>
        </a-form-model-item>
        <a-form-model-item label="版本" prop="specVersion">
          <a-input placeholder="" v-model.trim="form.specVersion" />
        </a-form-model-item>
        <a-form-model-item label="版本提交时间" prop="submitTime">
          <a-date-picker placeholder="" v-model="form.submitTime" style="width: 100%" />
        </a-form-model-item>
      </a-form-model>
    </j-form-container>
    </a-spin>
	<SelectProductModal ref="selectModal" @ok="selectOK"></SelectProductModal>
  </z-modal>
</template>

<script>
import ModalFormMixin from '@/mixins/ModalFormMixin'
import SelectProductModal from '@/pages/crm/product/modules/SelectProductModal'
import JFormContainer from '@/components/form/JFormContainer'

export default {
  name: "crmSpecificationModal",
  mixins: [ModalFormMixin],
  components: {
    JFormContainer,
	  SelectProductModal
  },
  data() {
    return {
      validatorRules: {
        specName: [
          { required: true, message: '请输入规格名称!' }
        ],
      },
      url: {
        add: '/specification/add',
        edit: '/specification/edit'
      },
      // 查询参数
      queryParam: {},
      selectedRowKeys: [],
      selectedRows: [],
      toggleSearchStatus: false
    }
  },
  methods: {
    addAfter() {
    },
	onSearchProduct() {
	  this.$refs.selectModal.showModal()
	},
	selectOK(rows, idstr) {
	  if(!rows){
	    this.form.productId = ''
	    this.form.productName = ''
	  }else{
	    let row = rows[0]
	    this.form.productId = row.id
	    this.form.productName = row.name
	  }
	  this.form = Object.assign({},this.form)
	}
  }
}
</script>
